package com.xmhmyh.generalframework.project.sys.conversion;

import com.xmhmyh.generalframework.project.sys.dto.DictionaryDTO;
import com.xmhmyh.generalframework.project.sys.entity.Dictionary;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: 于丁
 * @DateTime: 2020/8/11 4:03 下午
 */
public class Dictionary2DictionaryDTOConversion {

    public static DictionaryDTO conversion(Dictionary dictionary) {
        DictionaryDTO dictionaryDTO = new DictionaryDTO();
        dictionaryDTO.setId(dictionary.getId());
        dictionaryDTO.setName(dictionary.getName());
        dictionaryDTO.setCode(dictionary.getCode());
        dictionaryDTO.setValue(dictionary.getValue());
        dictionaryDTO.setParentsId(dictionary.getParentsId());
        dictionaryDTO.setLvl(dictionary.getLvl());
        dictionaryDTO.setRemark(dictionary.getRemark());
        dictionaryDTO.setAccountType(dictionary.getAccountType());
        dictionaryDTO.setType(dictionary.getType());
        return dictionaryDTO;
    }

    public static List<DictionaryDTO> conversion(List<Dictionary> dictionaryList) {
        return dictionaryList.stream().map(dictionary -> {
            return conversion(dictionary);
        }).collect(Collectors.toList());
    }
}
